import {Button} from 'antd'
import { useEffect } from 'react';
import {redirect, useNavigate}from 'react-router-dom'
function Logout(){
    const navigate = useNavigate()
 const out = ()=>{
   
    localStorage.removeItem("token")
      // eslint-disable-next-line no-restricted-globals

       navigate("/")

  
   
 }
 useEffect(()=>{
   const token =localStorage.getItem("token")
   if(token){
      navigate("/home/logout")
   }
   else{
      navigate("/err")
   }
 })
    return(
    <>
    <h1>退出后台登录系统</h1><br></br>
    <Button type="primary" onClick={out}>用户退出</Button>
    </>
    )
}
export default  Logout
